package cn.controller;

import cn.pojo.HealthAbnormalPerson;
import cn.service.impl.HealthAbnormalPersonServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/abnormal")
public class HealthAbnormalPersonController {

    @Autowired
    private HealthAbnormalPersonServiceImpl abnormalPersonService;
    @PostMapping("/add")
    public Map<String, Object> save(HealthAbnormalPerson person) {
        return abnormalPersonService.save(person);
    }

    @PostMapping("/update")
    public Map<String, Object> update(HealthAbnormalPerson person) {
        if (person.getAbnormalStatusP() != null) {
            person.setAbnormalStatusP(person.getAbnormalStatusP() + 1);
        }
        return abnormalPersonService.update(person);
    }

    @GetMapping("/delete")
    public Map<String, Object> delete(Integer no) {
        return abnormalPersonService.delete(no);
    }

    @GetMapping("/select")
    public Map<String, Object> select(String userId, String kind) {
        return abnormalPersonService.select(userId, kind);
    }
}
